<!-- 登录界面模板 -->
<template>
    <div>
      <h1>登录界面</h1>
      <form @submit.prevent="handleFormSubmit">
        <input type="text" placeholder="账号" v-model="username" />
        <input type="password" placeholder="密码" v-model="password" />
        <button type="submit">登录</button>
        <p v-if="error">{{ error }}</p>
      </form>
      <hr/>
      <RouterView/>
    </div>
</template>

<script setup>
import { useRouter } from "vue-router";
let username = "";
let password = "";
let error = "";
const router = useRouter();

const handleFormSubmit = () => {
  if (username === "admin" && password === "admin") {
    router.push("/HomePage");
  } else {
    error = "账号或密码不正确";
    username = "";
    password = "";
  }
};
</script>



  